package com.itheima.tlias.config;

import com.itheima.tlias.web.interceptors.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author ghy
 * @version 1.0.1
 * @date 2024-01-30 11:36:48
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    //@Autowired
    //private MyInterceptor myInterceptor;

    //@Autowired
    //private MyInterceptor2 myInterceptor2;

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        /*registry.addInterceptor(myInterceptor)   //加入拦截器
                .addPathPatterns("/**")   //指定拦截路径
                .excludePathPatterns("/login")   //指定不拦截的路径
                .order(1);   //指定执行时间

        registry.addInterceptor(myInterceptor2)   //加入拦截器
                .addPathPatterns("/**")   //指定拦截路径
                .excludePathPatterns("/login")   //指定不拦截的路径
                .order(0);*/
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/login");
    }
}
